package com.qzd.springclude.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.client.RestTemplate;

import com.netflix.loadbalancer.IRule;
import com.netflix.loadbalancer.RandomRule;

@Configuration
public class ConfigBean {
	@Bean
	@LoadBalanced  //负载均衡(默认为轮询：表示为消费者访问多个生产者时访问那个)
	public RestTemplate getRestTemplate(){
		return new RestTemplate();
	}
	@Bean
	public IRule myIRule(){
		return new RandomRule();//随机的负载均衡
	}
	
}
